/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Tan_anotadorDAOImpl implements orm.dao.Tan_anotadorDAO {
	public Tan_anotador loadTan_anotadorByORMID(int anot_id) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return loadTan_anotadorByORMID(session, anot_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador getTan_anotadorByORMID(int anot_id) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return getTan_anotadorByORMID(session, anot_id);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador loadTan_anotadorByORMID(int anot_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return loadTan_anotadorByORMID(session, anot_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador getTan_anotadorByORMID(int anot_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return getTan_anotadorByORMID(session, anot_id, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador loadTan_anotadorByORMID(PersistentSession session, int anot_id) throws PersistentException {
		try {
			return (Tan_anotador) session.load(orm.Tan_anotador.class, new Integer(anot_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador getTan_anotadorByORMID(PersistentSession session, int anot_id) throws PersistentException {
		try {
			return (Tan_anotador) session.get(orm.Tan_anotador.class, new Integer(anot_id));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador loadTan_anotadorByORMID(PersistentSession session, int anot_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tan_anotador) session.load(orm.Tan_anotador.class, new Integer(anot_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador getTan_anotadorByORMID(PersistentSession session, int anot_id, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Tan_anotador) session.get(orm.Tan_anotador.class, new Integer(anot_id), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador[] listTan_anotadorByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return listTan_anotadorByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador[] listTan_anotadorByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return listTan_anotadorByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador[] listTan_anotadorByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tan_anotador as Tan_anotador");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Tan_anotador[]) list.toArray(new Tan_anotador[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador[] listTan_anotadorByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tan_anotador as Tan_anotador");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Tan_anotador[]) list.toArray(new Tan_anotador[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador loadTan_anotadorByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return loadTan_anotadorByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador loadTan_anotadorByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return loadTan_anotadorByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador loadTan_anotadorByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Tan_anotador[] tan_anotadors = listTan_anotadorByQuery(session, condition, orderBy);
		if (tan_anotadors != null && tan_anotadors.length > 0)
			return tan_anotadors[0];
		else
			return null;
	}
	
	public Tan_anotador loadTan_anotadorByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Tan_anotador[] tan_anotadors = listTan_anotadorByQuery(session, condition, orderBy, lockMode);
		if (tan_anotadors != null && tan_anotadors.length > 0)
			return tan_anotadors[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTan_anotadorByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return iterateTan_anotadorByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTan_anotadorByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.AnotacionPersistentManager.instance().getSession();
			return iterateTan_anotadorByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTan_anotadorByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tan_anotador as Tan_anotador");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTan_anotadorByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Tan_anotador as Tan_anotador");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador createTan_anotador() {
		return new orm.Tan_anotador();
	}
	
	public boolean save(orm.Tan_anotador tan_anotador) throws PersistentException {
		try {
			orm.AnotacionPersistentManager.instance().saveObject(tan_anotador);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Tan_anotador tan_anotador) throws PersistentException {
		try {
			orm.AnotacionPersistentManager.instance().deleteObject(tan_anotador);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tan_anotador tan_anotador)throws PersistentException {
		try {
			orm.Tan_anotacion[] lTan_anotacions = tan_anotador.tan_anotacion.toArray();
			for(int i = 0; i < lTan_anotacions.length; i++) {
				lTan_anotacions[i].setTan_anotadoranot(null);
			}
			return delete(tan_anotador);
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean deleteAndDissociate(orm.Tan_anotador tan_anotador, org.orm.PersistentSession session)throws PersistentException {
		try {
			orm.Tan_anotacion[] lTan_anotacions = tan_anotador.tan_anotacion.toArray();
			for(int i = 0; i < lTan_anotacions.length; i++) {
				lTan_anotacions[i].setTan_anotadoranot(null);
			}
			try {
				session.delete(tan_anotador);
				return true;
			} catch (Exception e) {
				return false;
			}
		}
		catch(Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Tan_anotador tan_anotador) throws PersistentException {
		try {
			orm.AnotacionPersistentManager.instance().getSession().refresh(tan_anotador);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Tan_anotador tan_anotador) throws PersistentException {
		try {
			orm.AnotacionPersistentManager.instance().getSession().evict(tan_anotador);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Tan_anotador loadTan_anotadorByCriteria(Tan_anotadorCriteria tan_anotadorCriteria) {
		Tan_anotador[] tan_anotadors = listTan_anotadorByCriteria(tan_anotadorCriteria);
		if(tan_anotadors == null || tan_anotadors.length == 0) {
			return null;
		}
		return tan_anotadors[0];
	}
	
	public Tan_anotador[] listTan_anotadorByCriteria(Tan_anotadorCriteria tan_anotadorCriteria) {
		return tan_anotadorCriteria.listTan_anotador();
	}
}
